package launch.world;

import launch.ChannelServer;
import packet.transfer.write.Packet;

public class WorldBroadcasting {

    public static void broadcastMessage(byte[] data) {
        broadcast(data);
    }

    public static void broadcastMessage(Packet data) {
        broadcast(data);
    }

    public static void broadcast(Packet data) {
        for (ChannelServer cserv : ChannelServer.getAllInstances()) {
            cserv.broadcastPacket(data);
        }
    }

    public static void broadcast(byte[] data) {
        for (ChannelServer cserv : ChannelServer.getAllInstances()) {
            cserv.broadcastPacket(new Packet(data));
        }
    }

    public static void broadcastSmega(byte[] data) {
        for (ChannelServer cserv : ChannelServer.getAllInstances()) {
            cserv.broadcastSmegaPacket(new Packet(data));
        }
    }

    public static void broadcastGM(byte[] data) {
        for (ChannelServer cserv : ChannelServer.getAllInstances()) {
            cserv.broadcastGMPacket(new Packet(data));
        }
    }

    public static void loggedOff(String name, int characterId, int channel, int[] buddies) {
        for (ChannelServer cserv : ChannelServer.getAllInstances())
            cserv.updateBuddies(characterId, channel, buddies, true);
    }

    public static void loggedOn(String name, int characterId, int channel, int buddies[]) {
        for (ChannelServer cserv : ChannelServer.getAllInstances())
            cserv.updateBuddies(characterId, channel, buddies, false);
    }
}
